(function () {
	var serverData = {};
    var serverTable;
    //查询
    jQuery('#search_btn').on('click',function(){
        /*serverData.year=jQuery('#sel').val();
        serverData.month=jQuery('#sele').val();*/
    	var begindate = jQuery('#begindate').val();
    	var enddate = jQuery('#enddate').val();
    	var typee = jQuery('#sele').val();
        serverData.begindate=begindate;
        serverData.enddate=enddate;
        serverData.typee=typee;
        serverTable.draw();
    })
    //撤销查询
    jQuery('#reset').on("click",function()
    {
        jQuery('#search').val('');
        serverData.key ='';
        serverTable.draw();
    });
    
    jQuery(document).ready(function () { 
    	var date = new Date();
    	//本月1日
    	var begindate = date.getFullYear()+"-"+(date.getMonth()+1)+"-01";
    	if(date.getMonth()+1 == 12){
    		//12月年+1；为明年1月1日
    		var enddate = (date.getFullYear()+1)+"-01-01";
    	}else{
    		var enddate = date.getFullYear()+"-"+(date.getMonth()+2)+"-01";
    	}
    	var typee = "主机";
    	serverData.begindate=begindate;
        serverData.enddate=enddate;
        serverData.typee=typee;
        serverTable = jQuery('#dataTable').DataTable({
        	"serverSide": true,
        	"ordering": false,
        	"pageLength" : -1,
        	"ajax": {
        		"dataType": "json",
        		"type": "get",
        		"cache": false,
        		"url":window.rootPath+ '/ui/paidPartsInternal/getTwo',
        		"data": function (d) {
        			return $.extend({}, d, serverData);
        		}
        	},
            "columns" : [{
			                data: null,
			                defaultContent : ""// 排序   1
			            },
			            {
        	                data: 'dutyPersonName'
        	                
        	            },
        	            {
        	                data: 'areaName'
        	                
        	            },
        	            {
        	                data: 'nPaidSum'
        	                
        	            }],
            "drawCallback": function (oSettings) {
                var k = 0;
                var total = oSettings.aiDisplay.length + oSettings._iDisplayStart;

                for (var i = oSettings._iDisplayStart, iLen = total; i < iLen; i++) {
                    $('td:eq(0)', oSettings.aoData[oSettings.aiDisplay[k]].nTr).text(i + 1);
                    k++;
                }
            }
        });
    });
})();
